package com.xyd.Service;

import com.xyd.dao.UserMapper;
import com.xyd.bean.User;
import com.xyd.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class UserService {
    SqlSession sqlSession = SqlSessionFactoryUtil.getSqlSession();
    UserMapper userMapper = sqlSession.getMapper(UserMapper.class);

    public User regUser(String uname) {
        return userMapper.regUser(uname);
    }

    public int insertUser(String uname, String upass) {
        return userMapper.insertUser(uname, upass);
    }

    public User loginUser(String uname, String upass) {
        return userMapper.loginUser(uname, upass);
    }

    public List<User> getAll() {
        return userMapper.getAllUser();
    }

    public User getByUid(Integer uid) {
        return userMapper.getByUid(uid);
    }

    public int modifyByUid(User user) {
        return userMapper.updateByUid(user);
    }

    public int delByUid(Integer uid) {
        return userMapper.delByUid(uid);
    }

    public int addUser(User user) {
        return userMapper.insertAll(user);
    }
}
